package com.usian.article.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.api.article.ApArticleContentApi;
import com.usian.article.service.ApArticleContentService;
import com.usian.model.article.pojos.ApArticleContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Wrapper;

@RestController
@RequestMapping("/api/v1/articleContent")
public class ApArticleContentController implements ApArticleContentApi {

    @Autowired
    ApArticleContentService apArticleContentService;

    /**
     * admin 远程调用保存文章主表
     * @param apArticleContent
     * @return
     */
    @RequestMapping("/saveArticleContent")
    @Override
    public ApArticleContent saveArticleContent(@RequestBody ApArticleContent apArticleContent) {
        return apArticleContentService.saveArticleContent(apArticleContent);
    }

    /**
     * search 远程调用查询文章详情
     * @param articleId
     * @return
     */
    @PostMapping("/findArticleId")
    @Override
    public ApArticleContent findArticleId(@RequestParam Long articleId) {
        return apArticleContentService.getOne(Wrappers.<ApArticleContent>lambdaQuery()
                .eq(ApArticleContent::getArticleId,articleId));
    }
}
